import {
  createInbizSchema,
  createBaseSchema,
  createComponentStyleSchema,
  createDecoratorStyleSchema,
  createModelSchema,
  getDefalutDecoratorProps,
  createComponentLayout,
  createControllerSchema,
} from '@inbiz/setters';
export const defaultProps = {
  checkedChildren: 'EformSwitch.checkedChildren',
  unCheckedChildren: 'EformSwitch.unCheckedChildren',
  defaultChecked: false,
};
import { createBehavior, createResource } from '@inbiz/core';
import { EformSwitch } from './locale';
import { getPlatform } from '@inbiz/utils';

export const propsSchema = createInbizSchema({
  attribute: {
    ...createBaseSchema({
      checkedChildren: {
        type: 'string',
        'x-decorator': 'FormItem',
        'x-component': 'MultilingualInput',
      },
      unCheckedChildren: {
        type: 'string',
        'x-decorator': 'FormItem',
        'x-component': 'MultilingualInput',
      },
      defaultChecked: {
        type: 'boolean',
        'x-decorator': 'FormItem',
        'x-component': 'Switch',
      },
    }),
  },
  style: {
    ...createComponentStyleSchema(),
    ...createComponentLayout(),
    ...createDecoratorStyleSchema(),
  },
  senior: {
    ...createModelSchema(),
    // ...createSoureSchema(),
  },
  controller: createControllerSchema({
    events: [{
      name:'onChange',
      label:'数据变更'
    }]
  })
});

export const Behavior = createBehavior({
  name: 'EformSwitch',
  extends: ['Field'],
  selector: (node) => node.props?.['x-component'] === 'EformSwitch',
  designerLocales: EformSwitch,
  designerProps: { propsSchema },
});

export const Resource = createResource({
  icon: 'Swtich',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'string',
        title: {
          value: 'EformSwitch.title',
          status: true,
        },
        'x-decorator': 'FormItem',
        'x-component': 'EformSwitch',
        'x-component-props': defaultProps,
        'x-decorator-props': getDefalutDecoratorProps(getPlatform()),
      },
    },
  ],
});
